package com.itheima.health.service.impl;

import com.itheima.health.common.RocketMqConst;
import com.itheima.health.service.SmsService;
import com.itheima.health.pojo.MsgTask;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;

@Slf4j
@DubboService
public class SmsServiceImpl implements SmsService {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    @Override
    public void send(String type, String phone, String content) {

        //验证码日志输出
        log.info("[发送短信]phone:{}，content:{}",phone,content);
        //封装成短信发送任务，放入MQ
        rocketMQTemplate.convertAndSend(RocketMqConst.TOPIC_SMS_SEND,new MsgTask(type,phone,content));
    }
}
